-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: look at the underlying of a TermRef for a getter #24565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| jsig(erasedUnderlying, toplevel = toplevel, unboxedVCs = unboxedVCs) | ||
| else typeParamSig(ref.paramName.lastPart) | ||
|
|
||
| case ref: TermRef if ref.symbol.isGetter => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Equivalent in TypeErasure:
scala3/compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Lines 804 to 806 in fe49539
| private def underlyingOfTermRef(tp: TermRef)(using Context) = tp.widen match | |
| case tpw @ MethodType(Nil) if tp.symbol.isGetter => tpw.resultType | |
| case tpw => tpw |
| public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException | ||
| public final void java.lang.Object.wait() throws java.lang.InterruptedException | ||
| public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException | ||
| public int Foo.x() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this fix, we would have gotten:
public scala.Function0<java.lang.Object> Foo.x()
If the type of a
valis aTermRef, generating the generic signature based on the underlying type will produce the typescala.Function0<underlying>. The reason behind this is that during thegettersphase, the same symbol will now refer to the getter where the type will be=> <underlying>. Since theTermReforiginally intended to capture the underlying type of aval, we recover that information by directly checking the resultType of the getter.Closes #24553